package com.juanran.web.controller;

import com.github.pagehelper.Page;
import com.juanran.common.module.RestResult;
import com.juanran.domain.model.JuanranUser;
import com.juanran.mapper.JuanranUserMapper;
import com.juanran.service.JuanranUserService;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


@RestController
@Api(value = "/JuanranUser", tags = "用户表")
@ApiSort(value = 1)
@Slf4j
public class JuanranUserController {

    @Resource
    private JuanranUserService juanranUserService;

    @PostMapping("/JuanranUser/list")
    @ApiOperationSupport(order = 13)
    @ApiOperation(value = "根据条件查询用户表", notes = "根据条件查询用户表")
    public RestResult<List<JuanranUser>> queryJuanranUser(@RequestBody JuanranUser query) {
        List<JuanranUser> list = juanranUserService.list();
        return RestResult.success(list);
    }

    @PostMapping("/JuanranUser")
    @ApiOperation(value = "新增用户表", notes = "新增用户表")
    @ApiOperationSupport(order = 14)
    public RestResult<Object> insertJuanranUser(@ApiParam(value = "用户表Entity", required = true) @RequestBody JuanranUser entity) {
        juanranUserService.save(entity);
        return RestResult.success();
    }

    @GetMapping("/JuanranUser")
    @ApiOperation(value = "根据id查询用户表", notes = "根据id查询")
    @ApiOperationSupport(order = 15)
    public RestResult<JuanranUser> details(@RequestParam String entityId) {
        JuanranUser juanranUser = juanranUserService.getById(entityId);
        return RestResult.success(juanranUser);
    }


    @PutMapping("/JuanranUser")
    @ApiOperation(value = "修改用户表", notes = "修改用户表")
    @ApiOperationSupport(order = 16)
    public RestResult<Object> updateJuanranUser(@ApiParam(value = "用户表Entity", required = true) @RequestBody JuanranUser entity) {
        juanranUserService.updateById(entity);
        return RestResult.success();
    }

    @DeleteMapping("/JuanranUser")
    @ApiOperationSupport(order = 17)
    @ApiOperation(value = "根据ID删除用户表", notes = "根据ID删除")
    public RestResult<Object> removeById(@RequestParam String entityId) {
        juanranUserService.removeById(entityId);
        return RestResult.success();
    }

}
